const dataTimeFormat = l => val => val ? `${val.slice(l - 4, l - 2)}:${val.slice(l - 2, l)}` : '';

const dataTimeFormat4 = dataTimeFormat(4)

const dataTimeFormat12 = dataTimeFormat(12)       // yyyyMMddHHss & HHss to HH:ss

const dataTimeFormatAll = val => val.toString().replace(/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})/, `$1-$2-$3 $4:$5`)  // yyyyMMddHHss to yyyy-MM-dd HH:ss

const pointFormat = d => d.slice(-4).replace(/(^.{2})/, '$1.');   // to  _ _. _ _
const dashFormat = d => d.slice(0, 8).replace(/(\d{4})(\d{2})(\d{2})/, `$1-$2-$3`);   // yyyyMMdd to  yyyy-MM-dd

export {
  dataTimeFormat4,
  dataTimeFormat12,
  dataTimeFormatAll,
  pointFormat,
  dashFormat
}
